<template>
  <div class="process-navigation">
    <div
      v-for="(step, index) in steps"
      :key="index"
      class="process-step"
      :class="{ 'active': currentStep === index, 'completed': currentStep > index }"
      @click="goToStep(step.route)"
    >
      <div class="step-icon">
        <i :class="step.icon"></i>
      </div>
      <div class="step-text">{{ step.text }}</div>
      <div class="step-connector" v-if="index < steps.length - 1"></div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentStep: 0, // 当前步骤索引
      steps: [
        { text: '委托单', icon: 'el-icon-user', route: '/step1' },
        { text: '派工单', icon: 'el-icon-document', route: '/step2' },
        { text: '维修领料', icon: 'el-icon-edit', route: '/step3' },
        { text: '财务结算', icon: 'el-icon-check', route: '/step4' },
        { text: '完成', icon: 'el-icon-success', route: '/complete' }
      ]
    }
  },
  methods: {
    goToStep(route) {
      this.$router.push(route)
    }
  }
}
</script>

<style scoped>
.process-navigation {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  margin-bottom: 30px;
}

.process-step {
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
}

.step-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  color: #fff;
  font-size: 18px;
  transition: all 0.3s;
}

.step-text {
  color: #666;
  font-size: 14px;
  transition: all 0.3s;
}

.step-connector {
  width: 80px;
  height: 2px;
  background-color: #e0e0e0;
  margin: 0 10px;
  transition: all 0.3s;
}

.process-step.active .step-icon {
  background-color: #409EFF;
}

.process-step.active .step-text {
  color: #409EFF;
  font-weight: bold;
}

.process-step.completed .step-icon {
  background-color: #67C23A;
}

.process-step.completed .step-text {
  color: #67C23A;
}

.process-step.completed .step-connector {
  background-color: #67C23A;
}
</style>
